core: pull: Fix regression from memory leak fixes
authorColin Walters <walters@verbum.org>
Sat, 5 May 2012 18:59:14 +0000 (14:59 -0400)
committerColin Walters <walters@verbum.org>
Sat, 5 May 2012 18:59:14 +0000 (14:59 -0400)
src/ostree/ostree-pull.c

index 75c06bbbe1282862ce79e7bb17eea9ae929df58c..976f36ae4b9a2f18d529a2bebe2f2964fdf5f4a5 100644 (file)
@@ -1072,7 +1072,7 @@ ostree_builtin_pull (int argc, char **argv, GFile *repo_path, GError **error)
   gpointer key, value;
   int i;
   GCancellable *cancellable = NULL;
-  ot_lfree char *tmpstr = NULL;
+  ot_lfree char *remote_key = NULL;
   ot_lobj OstreeRepo *repo = NULL;
   ot_lfree char *path = NULL;
   ot_lfree char *baseurl = NULL;
@@ -1116,8 +1116,8 @@ ostree_builtin_pull (int argc, char **argv, GFile *repo_path, GError **error)
 
   config = ostree_repo_get_config (repo);
 
-  tmpstr = g_strdup_printf ("remote \"%s\"", pull_data->remote_name);
-  baseurl = g_key_file_get_string (config, tmpstr, "url", error);
+  remote_key = g_strdup_printf ("remote \"%s\"", pull_data->remote_name);
+  baseurl = g_key_file_get_string (config, remote_key, "url", error);
   if (!baseurl)
     goto out;
   pull_data->base_uri = soup_uri_new (baseurl);
@@ -1160,7 +1160,7 @@ ostree_builtin_pull (int argc, char **argv, GFile *repo_path, GError **error)
       GError *temp_error = NULL;
       gboolean fetch_all_refs;
 
-      configured_branches = g_key_file_get_string_list (config, key, "branches", NULL, &temp_error);
+      configured_branches = g_key_file_get_string_list (config, remote_key, "branches", NULL, &temp_error);
       if (configured_branches == NULL && temp_error != NULL)
         {
           if (g_error_matches (temp_error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_KEY_NOT_FOUND))
@@ -1193,9 +1193,9 @@ ostree_builtin_pull (int argc, char **argv, GFile *repo_path, GError **error)
         {
           char **branches_iter = configured_branches;
 
-          if (!*branches_iter)
+          if (!(branches_iter && *branches_iter))
             g_print ("No configured branches for remote %s\n", pull_data->remote_name);
-          for (;*branches_iter; branches_iter++)
+          for (;branches_iter && *branches_iter; branches_iter++)
             {
               const char *branch = *branches_iter;
               char *contents;